package com.ibeeking.found.open.api.feign;

import com.ibeeking.found.open.api.common.query.FileNameQuery;
import com.ibeeking.found.open.api.feign.fallback.OpenFileFeignFallbackFactory;
import com.ibeeking.nematos.file.oss.dto.OssPolicyDto;
import com.ibeeking.nematos.utils.result.ResponseResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;


/**
 * @Author ibeeking
 */
@FeignClient(name = "base-file-b-server", path = "/b", contextId = "openFileFeignClient", fallbackFactory = OpenFileFeignFallbackFactory.class, decode404 = true)
public interface OpenFileFeignClient {
    /**
     * 获取oss配置项
     *
     * @return
     */
    @GetMapping(value = "/file/feign/v1/policy")
    ResponseResult<OssPolicyDto> policy();
    /**
     * 获取文件流
     *
     * @param query
     * @return
     */
    @PostMapping(value = "/file/feign/v1/queryFile")
    feign.Response queryFile(@RequestBody FileNameQuery query);
    /**
     * 获取文件流
     *
     * @param query
     * @return
     */
    @PostMapping(value = "/file/feign/v1/downloadFile")
    ResponseResult<String> downloadFile(@RequestBody FileNameQuery query);
    /**
     * 获取文件流
     *
     * @param file
     * @return
     */
    @RequestMapping(method = RequestMethod.POST, value = "/file/feign/v1/upload",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    ResponseResult<String> uploadFile(@RequestPart("file") MultipartFile file) throws IOException;

}
